﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HCSAnalyzer.Classes.Base_Classes.DataStructures;

namespace HCSAnalyzer.Classes.Base_Components.Viewers.Designers
{
    public partial class FormForMultiChoice : Form
    {

        List<cExtendedControl> xListControl = new List<cExtendedControl>();

        public FormForMultiChoice(List<cExtendedControl> xListControl)
        {
            this.xListControl = xListControl;

            InitializeComponent();


            foreach (var item in this.xListControl)
            {
                this.listBoxTitle.Items.Add(item.Title);
            }
            //    TP.Width = 0;// TC.Width * 5;
            //    TP.Height = 0;// TC.Height * 5;

            //    TP.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom
            //  | System.Windows.Forms.AnchorStyles.Left| System.Windows.Forms.AnchorStyles.Right);

            //    item.Width = TP.Width;
            //    item.Height = TP.Height;
            //    item.Controls[0].Width = item.Width;
            //    item.Controls[0].Height = item.Height;
            
            
            xListControl[0].Width = this.splitContainer.Panel1.Width;
            xListControl[0].Height = this.splitContainer.Panel1.Height;
            xListControl[0].Controls[0].Width = xListControl[0].Width;
            xListControl[0].Controls[0].Height = xListControl[0].Height;

            

                    xListControl[0].Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom
              | System.Windows.Forms.AnchorStyles.Left| System.Windows.Forms.AnchorStyles.Right);
            this.splitContainer.Panel1.Controls.Add(xListControl[0]);


        }

        private void listBoxTitle_SelectedIndexChanged(object sender, EventArgs e)
        {

            this.splitContainer.Panel1.Controls.Clear();
            for (int i = 0; i < this.xListControl.Count; i++)
            {
                //if(((ListBox)sender).SelectedItem
                if (((ListBox)sender).SelectedItem == null) return;

                if (xListControl[i].Title == ((ListBox)sender).SelectedItem.ToString())
                {
                    xListControl[i].Visible = false;
                    xListControl[i].Width = this.splitContainer.Panel1.Width ;
                    xListControl[i].Height = this.splitContainer.Panel1.Height;
                    xListControl[i].Controls[0].Width = xListControl[i].Width;
                    xListControl[i].Controls[0].Height = xListControl[i].Height;

                    xListControl[i].Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom
                                            | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);

                    this.splitContainer.Panel1.Controls.Add(xListControl[i]);
                    xListControl[i].Visible = true;
                    return;

                }

            }




        }
    }
}
